package info.fastpace.utils;

import java.util.concurrent.ConcurrentLinkedQueue;

public class Observable<T> {

	private ConcurrentLinkedQueue<Observer<T>> observers = new ConcurrentLinkedQueue<Observer<T>>();
	
	public void addObserver(Observer<T> observer) {
		observers.add(observer);
	}
	
	public void removeObserver(Observer<T> observer) {
		observers.remove(observer);
	}
	
	public void notifyObservers(T arg) {
		for (Observer<T> observer : observers) {
			observer.update(arg);
		}
	}
	
	public void clearObservers() {
		observers.clear();
	}
}
